package pl.elka.pobr.ppr.utils;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;

/**
 * BufferedImageConverter.java -- static class containing a method to convert a java.awt.image.BufferedImage into a java.awt.Image
 */
public class BufferedImageConverter {

    // default version of createBufferedImage
    static public BufferedImage createBufferedImage(Image imageIn) {
        return createBufferedImage(imageIn, BufferedImage.TYPE_INT_ARGB);
    }

    static public BufferedImage createBufferedImage(Image imageIn, int imageType) {
        BufferedImage bufferedImageOut = new BufferedImage(imageIn.getWidth(null), imageIn.getHeight(null), imageType);
        Graphics g = bufferedImageOut.getGraphics();
        g.drawImage(imageIn, 0, 0, null);
        return bufferedImageOut;
    }
}
